package example.net;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by lenovo on 2016/11/7 0007.
 * 获取url的头信息
 */
public class UrlHeader {
    public static void main(String[] args) throws IOException {
        URL url = new URL("http://www.w3cschool.cc");
        URLConnection conn = url.openConnection();

        Map<String, List<String>> headers = conn.getHeaderFields();
        Set<String> keys = headers.keySet();
        for (String key : keys) {
            String val = conn.getHeaderField(key);
            System.out.println(key + "    " + val);
        }
        System.out.println(conn.getLastModified());
    }
}
